<template>
  <div class="test-form-view">
    <el-card shadow="hover" class="form-card">
      <ExperimentForm
        :project-param-config="foamBoardConfig"
        :show-cancel-btn="true"
        @submit="handleFormSubmit"
        @cancel="handleCancel"
      />
    </el-card>
  </div>
</template>

<script>
import ExperimentForm from '@/components/experiment/ExperimentForm.vue';

export default {
  name: 'FoamBoardTestView',
  components: { ExperimentForm },
  data() {
    return {
      // 完整参数配置（支持直接访问数组元素：length[0].value）
      foamBoardConfig: {
  "projectId": "2",
  "projectName": "1",
  "standardCode": "1",
  "description": "",
  "paramGroups": [
    {
      "groupId": "GRPVENMTd",
      "groupName": "参数组2",
      "isNested": false,
      "allowDynamicRows": false,
      "maxRows": 3,
      "sortOrder": 2,
      "childGroups": [],
      "paramItems": [
        {
          "paramId": "PARAMkpglYW5V",
          "paramName": "新参数1",
          "paramCode": "a_ui8b",
          "dataType": "text",
          "paramType": "base",
          "unit": "",
          "required": false,
          "calculationExpr": "",
          "dependencies": [],
          "options": [],
          "validateRule": {},
          "conditionShow": {},
          "precision": 1,
          "columnWidth": 120,
          "placeholder": "",
          "isMultiMeasure": false,
          "multiMeasureCount": 1,
          "sortOrder": 1
        },
        {
          "paramId": "PARAMLQoGTiTn",
          "paramName": "新参数2",
          "paramCode": "a_udfi",
          "dataType": "text",
          "paramType": "base",
          "unit": "",
          "required": false,
          "calculationExpr": "",
          "dependencies": [],
          "options": [],
          "validateRule": {},
          "conditionShow": {},
          "precision": 1,
          "columnWidth": 120,
          "placeholder": "",
          "isMultiMeasure": false,
          "multiMeasureCount": 1,
          "sortOrder": 2
        }
      ]
    },
    {
      "groupId": "GRP0yBIZl",
      "groupName": "参数组2",
      "isNested": true,
      "allowDynamicRows": false,
      "maxRows": 3,
      "sortOrder": 2,
      "childGroups": [
        {
          "groupId": "GRP0yBIZl_CH66Sl",
          "groupName": "子组1",
          "paramItems": [
            {
              "paramId": "PARAM507QIVU8",
              "paramName": "新参数3",
              "paramCode": "a_xqgx",
              "dataType": "text",
              "paramType": "base",
              "unit": "",
              "required": false,
              "calculationExpr": "",
              "dependencies": [],
              "options": [],
              "validateRule": {},
              "conditionShow": {},
              "precision": 1,
              "columnWidth": 120,
              "placeholder": "",
              "isMultiMeasure": false,
              "multiMeasureCount": 1,
              "sortOrder": 1
            },
            {
              "paramId": "PARAMd8Tp8zYZ",
              "paramName": "新参数4",
              "paramCode": "a_390n",
              "dataType": "text",
              "paramType": "base",
              "unit": "",
              "required": false,
              "calculationExpr": "",
              "dependencies": [],
              "options": [],
              "validateRule": {},
              "conditionShow": {},
              "precision": 1,
              "columnWidth": 120,
              "placeholder": "",
              "isMultiMeasure": false,
              "multiMeasureCount": 1,
              "sortOrder": 2
            }
          ]
        },
        {
          "groupId": "GRP0yBIZl_CHmkfd",
          "groupName": "子组2",
          "paramItems": [
            {
              "paramId": "PARAM5qpzSRdM",
              "paramName": "新参数5",
              "paramCode": "a_4t2t",
              "dataType": "text",
              "paramType": "base",
              "unit": "",
              "required": false,
              "calculationExpr": "",
              "dependencies": [],
              "options": [],
              "validateRule": {},
              "conditionShow": {},
              "precision": 1,
              "columnWidth": 120,
              "placeholder": "",
              "isMultiMeasure": false,
              "multiMeasureCount": 1,
              "sortOrder": 1
            },
            {
              "paramId": "PARAMo5jiZRGW",
              "paramName": "新参数6",
              "paramCode": "a_sc4j",
              "dataType": "number",
              "paramType": "calculation",
              "unit": "",
              "required": false,
              "calculationExpr": "ROUND(a_ui8b * 1.0, 2)",
              "dependencies": [
                "a_ui8b",
                "a_udfi"
              ],
              "options": [],
              "validateRule": {},
              "conditionShow": {},
              "precision": 1,
              "columnWidth": 120,
              "placeholder": "",
              "isMultiMeasure": false,
              "multiMeasureCount": 1,
              "sortOrder": 2
            }
          ]
        }
      ],
      "paramItems": []
    },
    {
      "groupId": "GRPV25tsl",
      "groupName": "参数组3",
      "isNested": false,
      "allowDynamicRows": true,
      "maxRows": 3,
      "sortOrder": 3,
      "childGroups": [],
      "paramItems": [
        {
          "paramId": "PARAMHPXzBu3J",
          "paramName": "新参数7",
          "paramCode": "a_ddoi",
          "dataType": "text",
          "paramType": "base",
          "unit": "",
          "required": false,
          "calculationExpr": "",
          "dependencies": [],
          "options": [],
          "validateRule": {},
          "conditionShow": {},
          "precision": 1,
          "columnWidth": 120,
          "placeholder": "",
          "isMultiMeasure": false,
          "multiMeasureCount": 1,
          "sortOrder": 1
        },
        {
          "paramId": "PARAMPTn8RUJC",
          "paramName": "新参数8",
          "paramCode": "a_01mv",
          "dataType": "text",
          "paramType": "base",
          "unit": "",
          "required": false,
          "calculationExpr": "",
          "dependencies": [],
          "options": [],
          "validateRule": {},
          "conditionShow": {},
          "precision": 1,
          "columnWidth": 120,
          "placeholder": "",
          "isMultiMeasure": false,
          "multiMeasureCount": 1,
          "sortOrder": 2
        }
      ]
    }
  ]
}
    };
  },
  methods: {
    handleFormSubmit(submitData) {
      console.log("提交的数据：", submitData);
      this.$message.success("检测数据提交成功！");
    },
    handleCancel() {
      this.$router.go(-1);
    }
  }
};
</script>

<style scoped>
.test-form-view {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}
.form-card {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}
</style>